package com.xr.util;

import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;

import java.util.Collection;

/**
 * key:value -> 1:n or n:1 or n:n
 *
 * Created by forvoyager@outlook.com on 2018-10-09 15:06.
 */
public final class MultimapUtil {
  private static final Multimap multimap = ArrayListMultimap.create();

  public static boolean put(Object k, Object v){
    return multimap.put(k, v);
  }

  public static Collection get(Object k){
    return multimap.get(k);
  }

  public static <T> T getOne(Object k){
    for(Object v : multimap.get(k)){
      return (T)v;
    }
    return null;
  }

}
